The invention relates to techniques for combining two or more images defined by color and alpha information to produce a new image also defined by color and alpha information.
The compositing of digital images is done with images defined by color information and alpha (also called transparency) information. The color information describes what color the image is at a particular location. The alpha information describes how much color there is at a particular locationxe2x80x94i.e., in simple, normal mode compositing, how much the color obscures the data that lies beneath it. If the images are considered as painted on sheets of acetate, then the color information describes the color of the paint while the alpha information describes its density.
Colors are generally represented by one or more color components, sometimes referred to as colorants. For example, a color video cathode ray tube can reproduce a significant fraction of the range of visible colors using a mixture of red, green, and blue light. Because of impurities in the inks and other physical limitations, printed color generally uses four inks: cyan, magenta, yellow, and black (CMYK).
To represent the color and alpha information in an image at a particular location in the image, a number for every color component and a number for the alpha value is required. The color values can cover arbitrary ranges; however, these are generally normalized to the range of zero to one, and the range of zero to one will be used in the examples of this specification. Similarly, this specification will treat alpha values in the conventional way as having a range from zero (fully transparent) to one (fully opaque).
In many compositing operations, the compositing operation uses the result of multiplying the color component values by the alpha value. This results in a format known as pre-multiplied alpha. One benefit of this format is that it resolves the question of what color the fully transparent regions have by multiplying it with zero and thereby arriving at zero as the value for the pre-multiplied color components. Thus,  less than C0, C1, . . . , Cn, A greater than  is transformed into  less than C0*A, C1*A, . . . , Cn*A, A greater than . (The notation  less than  . . .  greater than  indicates a vector of elements that defines a color, where Ci is the value of the i-th color component, A is the value of alpha, and * is the scalar multiplication operator. The values Ci and A are generally normalized to range from zero to one, inclusive.)
The case of pre-multiplied alpha can be generalized to matted images by specifying that the color values are stored as if the image had been blended (matted) against some particular background using linear interpolation on the components. Pre-multiplied alpha corresponds to matting against the color with all components zero. The vector from above now becomes  less than C0*A+M0*(1xe2x88x92A), . . . , Cn*A+Mn*(1xe2x88x92A), A greater than . (The Mi is value of the i-th color component of the matting color.)
What has been described so far is a shared-alpha format, in which all of the color components have the same alpha value. The shared-alpha format can be generalized to a per-component alpha by associating an alpha value Ai with each component, thus yielding:
 less than  less than C0, A0 greater than ,  less than C1, A1 greater than , . . . ,  less than Cn, An  greater than  greater than .
As long as compositing operations are separablexe2x80x94i.e., can be applied to each color component independentlyxe2x80x94each component is composited as if it were a grayscale image with a single alpha value. The matted version of per-component alpha looks like this:
 less than  less than C0*A0+M0*(1xe2x88x92A0), A0 greater than , . . . ,  less than Cn*An+Mn*(1xe2x88x92An), An  greater than  greater than . 
The present invention provides methods and apparatus including computer program products for combining source images to form a final image, each image being a digital image defined by color component values and a transparency value. The invention performs the steps of receiving two or more source images, each defined by color component and alpha information; assembling a new, mixed image in per-component format by applying a selection operation on the color and alpha information of the source images to define color component and alpha information of the new image according to a source selection definition; and converting the new per-component image into a shared-alpha format to generate the final image in shared-alpha format.
In general, in one aspect, the invention provides a technique for combining source images to form a final image, each image being a digital image defined by color component values and a transparency value. The technique includes converting each of two or more shared-alpha source images into corresponding per-component source images in which each color component value is paired with a per-component alpha value, the alpha value indicating to what extent color exists in a range of fully transparent to fully opaque; assembling a new image in per-component format by selecting each color and alpha pair for each component of the new image from exactly one of the source images in per-component format according to a source selection definition; and converting the new per-component image into shared-alpha format to generate the final image in shared-alpha format.
Embodiments may include one or more of the following features.
The new per-component image is a matted image having color and alpha pairs at each location of the image  less than  less than X0, A0 greater than , . . . ,  less than Xn, An greater than  greater than , the Xi being the color value of the new image of the i-th color component, the Ai being the alpha value paired with the i-th color component, and the image being matted with a matting color M having color component values Mi. The final image is in a matted shared-alpha format  less than C0, . . . , Cn, A greater than , the Ci being the color value of the i-th color component and the A being the shared alpha value. The Ci and A satisfy the two relationships Axe2x89xa7Max (Ai), where i ranges over the color components, and Ci=Xi. The A satisfies the relationship A=Max (Ai). The source images are converted into a matted format with the matting color M before the assembling of the new per-component image occurs.
The new per-component image can be a matted image having color and alpha pairs at each location of the image  less than  less than X0, A0 greater than , . . . ,  less than Xn, An greater than  greater than , the Xi being the matted color value of the i-th color component, the Ai being the alpha value paired with the i-th color component, and the image being matted with a matting color M having color component values Mi. The final image can be in an unmatted shared-alpha format.
The source images can be converted into a matted format with the matting color M before the assembling of the new per-component image occurs. The source images can be converted from an unmatted format. The source images can be converted from a matted format with a matting color different from M. The source selection definition may be location independent. The number of source images can be two. The color components can be cyan, magenta, yellow, and black and the matting color M can be white.
In another aspect, the present invention provides methods and apparatus including computer program products for combining source images to form a final image, each image being a digital image defined by color component values and a transparency value. The invention performs the steps of converting each of two or more unmatted, shared-alpha source images into a corresponding unmatted per-component source image in which each color component value is paired with a per-component alpha value, the alpha value indicating to what extent color exists in a range of fully transparent to fully opaque; assembling a new image in per-component format  less than  less than P0, A0 greater than , . . . ,  less than Pn, An greater than  greater than  by selecting each color and alpha pair for each component of the new image from exactly one of the per-component source images according to a source selection definition; and converting the new per-component image into a final unmatted shared-alpha image  less than C0, . . . , Cn, A greater than , the Ci being the color value of the i-th color component of the final image and the A being the shared alpha value of the final image, the Ci and A satisfying the two relationships
A=Max (Ai),
where i ranges over the color components, and
Ci=Pi*(Ai/A)+Mi*(1xe2x88x92(Ai/A)),
where Mi is the color value of the i-th color component of a matting color.
In another aspect, the present invention provides methods and apparatus including computer program products for converting an image in a per-component format into an image in a shared-alpha format. The invention performs the steps of receiving a matted per-component image having color and alpha pairs at each location representable as  less than  less than X0, A0 greater than , . . . ,  less than Xn, An greater than  greater than , the Xi being the matted color value of the i-th color component and the Ai being the alpha value paired with the i-th color component of the per-component image; and calculating the color values and alpha of a shared-alpha image representable as  less than C0, . . . , Cn, A greater than , the Ci being the color value of the i-th color component and the A being the shared alpha value, the Ci and A being calculated to satisfy the relationships
Axe2x89xa7Max (Ai),
where i ranges over the color components, and
Ci=(Xixe2x88x92Mi*(1xe2x88x92A))/A,
where Mi is the color value of the i-th color component of a matting color.
In another aspect, the present invention provides methods and apparatus including computer program products for converting an image in a per-component format into an image in a shared-alpha format. The invention performs the steps of receiving an unmatted per-component image having color and alpha pairs at each location representable as  less than  less than P0, A0 greater than , . . . ,  less than Pn, An greater than  greater than , the Pi being the color value of the i-th color component and the Ai being the alpha value paired with the i-th color component of the per-component image; and calculating the color values and alpha of an unmatted shared-alpha image representable as  less than C0, . . . , Cn, A greater than , the Ci being the color value of the i-th color component and the A being the shared alpha value, the Ci and A being calculated to satisfy the relationships
Axe2x89xa7Max(Ai),
where i ranges over the color components, and
Ci=Pi*(Ai/A)+Mi*(1xe2x88x92(Ai/A)),
where Mi is the color value of the i-th color component of a matting color.
In another aspect, the present invention provides methods and apparatus including computer program products for overprinting an element into a base image having transparency. The invention performs the steps of marking an element into a base image; and using component-restricted blending to blend the base image from before the marking operation with the base image after the marking operation to generate a final image in which one or more excluded color components match closely in the base image, whereby only a subset of the color components of the resulting base image appear to have been marked.
In another aspect, the present invention provides methods and apparatus including computer program products for combining source images to form a final image, each image being a digital image defined by color component values and a transparency value. The invention performs the steps of receiving two or more source images, each defined by color component and alpha information; assembling a new, mixed image in per-component format by applying a selection operation on the color and alpha information of the source images to define color component and alpha information of the new image according to a source selection definition; and converting the new per-component image into a shared-alpha format to generate the final image in shared-alpha format.
Embodiments may include the following features.
The source selection definition corresponds to a selection matrix with elements S(i, j), where i ranges over the color components, j ranges over the source images, and S(i, j) is the weight given to the contribution to the i-th color component and alpha of the mixed image from the i-th color component and alpha of the j-th source image.
The present invention also provides a general mechanism that can be used to blend a series of digital graphics elements together and then restrict the changes to a subset of the elements"" color components.
Advantages that can be seen in implementations of the invention include one or more of the following. Separating component restrictions from other aspects of blending provides flexibility in defining and implementing graphics operations. The invention allows overprinting and component restrictions to be implemented independently from other elements of a compositing process.